esp32: fix linker layout, UART/I2C clocking, and print interleaving - #5617
Closed
flrossetto wants to merge 1 commit into
Closed
esp32: fix linker layout, UART/I2C clocking, and print interleaving#5617flrossetto wants to merge 1 commit into
flrossetto wants to merge 1 commit into
Conversation
Found by cross-checking the esp32-generic target against the real esp-idf sources, after confirming the WiFi/BT blob crashes traced back here rather than to the blob itself. - targets/esp32.ld: IROM region was sized at a flat 4M instead of the real SOC_IROM_HIGH - SOC_IROM_LOW (0x330000) limit, and the .iram section pattern list was missing *(.coexsleepiram*), a WiFi/BT-blob section confirmed present via objdump on libcoexist.a. An unmapped section here means the blob's power-management ISR runs out of whatever memory happened to follow, which shows up as sporadic crashes during radio activity. - src/machine/machine_esp32.go: UART never set CONF0_TICK_REF_ALWAYS_ON, which only worked by luck on UART0 because the ROM bootloader happens to leave it in APB clock mode; any other UART or a cold path through this code gets the wrong clock source. Also fixes the baud divider to keep its fractional part instead of truncating to a bare integer division. - src/machine/machine_esp32_i2c.go: SCL_HIGH_PERIOD compensation was scaled by clock frequency (halfCycle/8) instead of using the fixed offset esp-idf's noise-filter formula actually calls for (thres+6, thres=7 → 13), producing wrong SCL timing at anything other than the frequency it happened to be tested at. - src/runtime/scheduler_cooperative.go: printlock/printunlock were no-ops, so two goroutines calling println concurrently can interleave their output mid-line on this cooperative scheduler (print can yield, e.g. waiting on a UART FIFO, before it finishes writing). Added a real bounded-wait lock. go.mod/go.sum: point tinygo.org/x/espflasher at flrossetto/espflasher (fix-esp32-chip-detect-and-stub-baud-cap) until that fix lands upstream — see that repo for details on the chip-detection and flash baud-rate fixes needed for reliable esp32-generic flashing.
deadprogram
reviewed
Aug 29, 2026
| tinygo.org/x/go-llvm v0.0.0-20260721072906-185673ef46a5 | ||
| ) | ||
|
|
||
| replace tinygo.org/x/espflasher => github.com/flrossetto/espflasher v0.0.0-20260827223712-de27f3043f8f |
Member
There was a problem hiding this comment.
You should not be using a fork here.
Member
|
Please only submit PRs that do a single thing. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by cross-checking the esp32-generic target against the real esp-idf sources, after confirming the WiFi/BT blob crashes traced back here rather than to the blob itself.
go.mod/go.sum: point tinygo.org/x/espflasher at flrossetto/espflasher (fix-esp32-chip-detect-and-stub-baud-cap) until that fix lands upstream — see that repo for details on the chip-detection and flash baud-rate fixes needed for reliable esp32-generic flashing.